package com.data.migration.vo;

/**
 * Created by Peter on 2018/12/7.
 */
public class Column {
    public static final String _string = "str";// 数据库中的类型根据写法分为两类，一类在写sql的时候需要单引号，定义为str，一类不需要单引号，定义为int
    public static final String _int = "int";

    public Column(String name, String type) {
        this.name = name;
        this.type = changeType(type);
        this._type = type;
    }

    private String changeType(String type) {
        if (type.contains("tinyint") || type.contains("smallint") || type.contains("mediumint") || type.contains("int") || type.contains("bigint") || type.contains("float") || type.contains("double") || type.contains("decimal")) {
            return _int;
        } else {
            return _string;
        }
    }

    private String name;
    private String type;// 数据库中的类型根据写法分为两类，一类在写sql的时候需要单引号，定义为str，一类不需要单引号，定义为int
    private String _type;//数据库中的类型

    public String get_type() {
        return _type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "    " + name + " " + type + " " + _type;
    }
}
